#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import os


class ConfigManager(object):
    # 项目目录
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

    # 日志目录
    LOG_PATH = os.path.join(BASE_DIR, 'logs')

    # 临时文件目录
    TMP_PATH = os.path.join(BASE_DIR, 'tmp')

    # 地址目录
    DATA_LINK_PATH = os.path.join(BASE_DIR, 'config')

    def tmp_file_path(self, file_name):
        """临时文件路径"""
        tmp_file = os.path.join(self.BASE_DIR, 'tmp', file_name)
        # if not os.path.exists(tmp_file):
        #     raise FileNotFoundError("配置文件%s不存在！" % tmp_file)
        return tmp_file

    def yaml_file(self, name):
        """yaml文件"""
        file_path = os.path.join(self.DATA_LINK_PATH, '%s.yaml' % name)
        if not os.path.exists(file_path):
            raise FileNotFoundError("%s 文件不存在！" % file_path)
        return file_path


cm = ConfigManager()
